<template>
	<view class="content">
		<view class="img" v-html="detailImg"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: '',
				title: '',
				detailImg: '',
				className: ''
			};
		},
		onShareAppMessage(res) {
			console.log(res, this.parent_id)
			let path = '/pages/case/caseDetail?parent_id=' + this.parent_id + '&id=' + this.id
				console.log(path)
			return {
				title: '小春科技',
				path
			}
		},
		
		onShow() {
			// #ifdef MP-BAIDU 
			swan.setPageInfo({
				title:"详情展示",
				keywords:"",
				description:"详情展示"
			})
			// #endif 
			if (uni.getStorageSync("user_id")) {
				this.user_id = uni.getStorageSync("user_id")
				this.getstate()
			}
			console.log(this.user_id)
		},
		onLoad(options) {
			console.log("options", options)
			if (getApp().globalData.parent_id == undefined) {
				console.log("options", options.parent_id)
				if (options.parent_id) {
					this.id = options.id
					this.parent_id = options.parent_id
					getApp().globalData.parent_id = options.parent_id
				} else {
					this.parent_id = 0
				}
			} else {
				this.parent_id = getApp().globalData.parent_id
			}
			if (uni.getStorageSync("user_id")) {
				this.user_id = uni.getStorageSync("user_id")
				this.getstate()
			}
			this.id = options.id
			this.fenleiId = options.fenleiId
			this.className = options.className
			console.log(this.fenleiId)
			console.log(this.className)
			console.log(options.page)
			getApp().globalData.type = this.fenleiId
			getApp().globalData.Name = this.className
			this.className
			// console.log(getApp().globalData.type)
			this.title = options.title
			uni.setNavigationBarTitle({
				title: this.title
			})
			this.getDetail()
		},
		methods: {
			// 用户状态
			getstate() {
				this.$http.post('/api/applet/get_sales_state', {
					user_id: this.user_id
				}).then(res => {
					console.log(Number(res.data))
					if (Number(res.data) > 0) {
						this.parent_id = this.user_id
					} else {
						this.parent_id = 0
					}
				})
			},
			getDetail() {
				this.$http.post('/api/applet/article', {
					id: this.id
				}).then(res => {
					console.log(res)
					if (res.code == 1) {
						this.detailImg = res.data
						console.log(this.detailImg)
						// this.detailImg = this.detailImg.replace(/\>/g, ' style="width:100%;max-width:100%;vertical-align: top;">');
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
</style>
